import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/*
 * operationUnitService.js - 业务实体定义 service
 * @date: 2018-10-24
 */
import request from 'utils/request';
import { parseParameters } from 'utils/utils';
import { CPAAS_PLATFORM } from 'utils/config';
/**
 * 查询业务实体列表
 * @param {Object} params - 查询参数
 */

export function queryOperationUnit(_x) {
  return _queryOperationUnit.apply(this, arguments);
}
/**
 * 新增或更新业务实体
 * @param {Object} params 新增或更新业务实体参数
 */

function _queryOperationUnit() {
  _queryOperationUnit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    var query;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            query = parseParameters(params);
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(params.tenantId, "/operation-units"), {
              method: 'GET',
              query: query
            }));

          case 2:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _queryOperationUnit.apply(this, arguments);
}

export function saveOperationUnit(_x2) {
  return _saveOperationUnit.apply(this, arguments);
}

function _saveOperationUnit() {
  _saveOperationUnit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    var list, tenantId;
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            list = params.list, tenantId = params.tenantId;
            return _context2.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(tenantId, "/operation-units"), {
              method: 'POST',
              body: list
            }));

          case 2:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _saveOperationUnit.apply(this, arguments);
}